package com.wilmer.carousel.service.impl;

import com.wilmer.common.utils.DateUtils;
import com.wilmer.carousel.domain.WechatCarousel;
import com.wilmer.carousel.domain.vo.ShowVo;
import com.wilmer.carousel.mapper.WechatCarouselMapper;
import com.wilmer.carousel.service.IWechatCarouselService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 轮播图Service业务层处理
 * 
 * @author hans
 * @date 2024-03-15
 */
@Service
public class WechatCarouselServiceImpl implements IWechatCarouselService 
{
    @Autowired
    private WechatCarouselMapper wechatCarouselMapper;

    /**
     * 查询轮播图
     * 
     * @param carouselId 轮播图主键
     * @return 轮播图
     */
    @Override
    public WechatCarousel selectWechatCarouselByCarouselId(Long carouselId)
    {
        return wechatCarouselMapper.selectWechatCarouselByCarouselId(carouselId);
    }

    @Override
    public int changeShow(ShowVo showVo) {
        return wechatCarouselMapper.isShow(showVo);
    }

    /**
     * 查询轮播图列表
     * 
     * @param wechatCarousel 轮播图
     * @return 轮播图
     */
    @Override
    public List<WechatCarousel> selectWechatCarouselList(WechatCarousel wechatCarousel)
    {
        return wechatCarouselMapper.selectWechatCarouselList(wechatCarousel);
    }

    /**
     * 新增轮播图
     * 
     * @param wechatCarousel 轮播图
     * @return 结果
     */
    @Override
    public int insertWechatCarousel(WechatCarousel wechatCarousel)
    {
        wechatCarousel.setCreateTime(DateUtils.getNowDate());
        return wechatCarouselMapper.insertWechatCarousel(wechatCarousel);
    }

    /**
     * 修改轮播图
     * 
     * @param wechatCarousel 轮播图
     * @return 结果
     */
    @Override
    public int updateWechatCarousel(WechatCarousel wechatCarousel)
    {
        wechatCarousel.setUpdateTime(DateUtils.getNowDate());
        return wechatCarouselMapper.updateWechatCarousel(wechatCarousel);
    }

    /**
     * 批量删除轮播图
     * 
     * @param carouselIds 需要删除的轮播图主键
     * @return 结果
     */
    @Override
    public int deleteWechatCarouselByCarouselIds(Long[] carouselIds)
    {
        return wechatCarouselMapper.deleteWechatCarouselByCarouselIds(carouselIds);
    }

    /**
     * 删除轮播图信息
     * 
     * @param carouselId 轮播图主键
     * @return 结果
     */
    @Override
    public int deleteWechatCarouselByCarouselId(Long carouselId)
    {
        return wechatCarouselMapper.deleteWechatCarouselByCarouselId(carouselId);
    }
}
